﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Manage_Supervise_complain : System.Web.UI.Page,HZ.MBSM.BLL.IPageDescribe
{
    protected void Page_Load(object sender, EventArgs e)
    {
        bandin();

    }
    private void bandin()
    {
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "Supervise";                                               //要查询的表明
        dbPage.Key = "AccountId";                                          //表的主键    
        dbPage.Where = selectWhere();                                           //查询条件    
        dbPage.SelectField = "AccountId,AreaId,case when class='1' then '省级' when  class='2'then '市级' when    class='3' then '县级' end class,SuperviseName,Address,PostCode,Telephone,Fax,SuperviseMan,Email,NetAddress";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request.QueryString["PG"]);             //设置需要查询第几页
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]); //设置需要查询第几页
        dbPage.PageSize = 15;                                                   //设置每页显示多少条记录 
        dbPage.OrderBy = "AccountId";                  //排序字段

        System.Data.IDataReader dr = dbPage.ExecuteReader();
        System.Text.StringBuilder sbt = new System.Text.StringBuilder();
        sbt.Append("<table width='98% style='border-collapse: collapse' >");
        sbt.Append("<tr class='table_title' nowrap>");
        sbt.Append("<td  style='word-break:break-all' width='15%'>监督机构名称</td>");
        sbt.Append("<td  style='word-break:break-all' width='9%'>级别</td>");
        sbt.Append("<td  style='word-break:break-all' width='13%'>地址</td>");
        sbt.Append("<td  style='word-break:break-all' width='15%'>邮政编码</td>");
        sbt.Append("<td  style='word-break:break-all' width='11%'>联系电话</td>");
        sbt.Append("<td  style='word-break:break-all' width='11%'>传真</td>");
        sbt.Append("<td  style='word-break:break-all' width='4%'>联系人</td>");
        sbt.Append("<td  style='word-break:break-all' width='15%'>网址</td>");
        sbt.Append("<td  style='word-break:break-all' width='4%'>选择</td>");
        sbt.Append(" </tr>");

        while (dr.Read())
        {
            sbt.Append("<tr>");
            sbt.Append("<td align='center'>" + SysFun.ToTrim(dr["SuperviseName"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["Class"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["Address"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["PostCode"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["Telephone"]) + "</td>");
            sbt.Append("<td align='center'>" + SysFun.ToTrim(dr["Fax"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["SuperviseMan"]) + "</td>");
            sbt.Append("<td align='left'>" + SysFun.ToTrim(dr["NetAddress"]) + "</td>");
        //    sbt.Append("<td align='left'>" + "<a target= _blank  href='mailto:" + SysFun.ToTrim(dr["Email"]) + "?subject=我向贵部投诉！&body="+ SysFun.ToTrim(dr["SuperviseName"]) +"各位领导您好！\n'>" + "投诉" + "</a> </td>");
            sbt.Append("<td align='left'>" + "<a target= _blank  href='AddTouSu.aspx?AccountIdAnswer=" + dr["Accountid"] + "&TouSuRen=" + SysFun.ToTrim(dr["SuperviseName"]) + "'>" + "投诉" + "</a> </td>");
            sbt.Append("</tr>");
           

        }

        sbt.Append("</table>");

        Label1.Text = sbt.ToString();
        dr.Close();
        dr = null;

        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键 

        dbPage.Db.Close();
        db.Close();
        db = null;
    }

    private string selectWhere() //查询条件 
    {
        string strSql = "", SuperviseName = txtname.Text.Trim().ToString(), Class = txtJb.Text.Trim().ToString();
        if (SuperviseName != "")
        {
            strSql += "SuperviseName like '%" + SuperviseName + "%' and";
        }
        if (Class == "省级" || Class == "省" ) Class = "1";
        else if (Class == "市级" || Class == "市") Class = "2";
        else if (Class == "县级" || Class == "县") Class = "3";
        else
        {
            Class = "";
        }
        if (Class != "")
        { 

            strSql += " Class = '" + Class + "' and";
        }
        if (strSql == "")
        {
            return "";
        }
        else
        {
            return strSql.Remove(strSql.Length - 3);
        }
    }
    #region IPageDescribe 成员

    public string Name
    {
        get { return "向监督机构投诉"; }
    }

    public string Describe
    {
        get { return "问题反馈"; }
    }

    public string ParentName
    {
        get { return "投诉管理"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
            return _AccountType;
        }
    }
    #endregion
}
